package top.songxs.gmall.product.rpc.biz.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.product.entity.SkuInfo;
import top.songxs.gmall.product.mapper.SkuInfoMapper;
import top.songxs.gmall.product.rpc.biz.SkuInfoFeignRpcService;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SkuInfoFeignRpcServiceImpl implements SkuInfoFeignRpcService {
    @Autowired
    private SkuInfoMapper skuInfoMapper;
    @Override
    public SkuInfo getSkuInfo(Long skuId) {
        return skuInfoMapper.getSkuInfo(skuId);
    }

    @Override
    public SkuInfo getPrice(Long skuId) {

        return skuInfoMapper.getPrice(skuId);
    }

    @Override
    public Result<List<Long>> getAllSkuId() {
       /* List<SkuInfo> skuInfos = skuInfoMapper.selectList(null);
        List<Long> ids = skuInfos.stream().map(SkuInfo::getId).collect(Collectors.toList());*/
        List<Long> ids = skuInfoMapper.getAllSkuId();
        return Result.ok(ids);
    }
}
